package com.boco.blch.analysiser.compliance.HW.manager;





import com.boco.blch.analysiser.compliance.ComplianceResolved;

/**
 * @author 黄戈
 * MPPDB 接口公开安全基线要求项 
 *
 */
public class BOCO_gbase_SecurityAbilityGuarantee_PublicInterface implements ComplianceResolved{
	
	private final static String GClusterStart="gcluster-start";
	private final static String GClusterEnd="gcluster-end";
	private final static String CorosyncStart="corosync-start";
	private final static String CorosyncEnd="corosync-end";
	

	@Override
	public int realEchoResolved(String echoResult) {
		
		int gclusterFlag=SUCCESS;
		int corosyncFlag=SUCCESS;
		
		if(!echoResult.equals("")&&echoResult!= null&&(!echoResult.contains(NoPermission1)&&!echoResult.contains(NoPermission2)&&!echoResult.contains(NoPermission3))){
		String gclusterResult=echoResult.substring(echoResult.indexOf(GClusterStart)+GClusterStart.length(),echoResult.indexOf(GClusterEnd)).trim();
		String corosyncResult=echoResult.substring(echoResult.indexOf(CorosyncStart)+CorosyncStart.length(),echoResult.indexOf(CorosyncEnd)).trim();
		if(gclusterResult.length()>0&&gclusterResult!=null){
		String[] gclusterResults = gclusterResult.split("\n"); 
		for (int i=0;i<gclusterResults.length;i++){
			if (gclusterResults[i].contains(":")&&!gclusterResults[i].contains(":5258")){
				gclusterFlag=FAILED;
				break;
			}else{
				gclusterFlag=SUCCESS;
			}
			
		}}else{
			gclusterFlag=UNKNOWN;
		}
		if(corosyncResult.length()>0&&corosyncResult!=null){
		String[] corosyncResults = corosyncResult.split("\n"); 
		for (int i=0;i<corosyncResults.length;i++){
			if (corosyncResults[i].contains(":")&&!corosyncResults[i].contains(":5493")){
				corosyncFlag=FAILED;
				break;
			}else{
				corosyncFlag=SUCCESS;
			}
			
		}}else{
			corosyncFlag=UNKNOWN;
		}
		System.out.println(gclusterFlag);
		System.out.println(corosyncFlag);
		 if(gclusterFlag==FAILED||corosyncFlag==FAILED){
				return FAILED;
			}else if(gclusterFlag==UNKNOWN&&corosyncFlag==UNKNOWN){
				return UNKNOWN;
			}else{
				return SUCCESS;
			}
	}else{
		return FAILED;
	}
  }
	
	/*
*/

}
